package com.huage.courseplatform.application.model.param;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;
import org.springframework.format.annotation.NumberFormat;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value="课程参数",description="参数")
public class CoursePARAM implements Serializable {
    private static final long serialVersionUID = 1L;

    @NotEmpty(message = "id不能为空", groups = Update.class)
    @ApiModelProperty(value = "主键id",required = true)
    private String id;

    @NotEmpty(message = "商户ID不能为空", groups = Insert.class)
    @ApiModelProperty(value = "商户ID",required = true)
    private String businessId;

    @NotEmpty(message = "课程负责老师ID不能为空", groups = Insert.class)
    @ApiModelProperty(value = "课程负责老师ID",required = true)
    private String teacherId;

    @NotEmpty(message = "课程名称不能为空", groups = Insert.class)
    @ApiModelProperty(value = "课程名称",required = true)
    private String courseName;

    @NotEmpty(message = "课程类型不能为空", groups = Insert.class)
    @ApiModelProperty(value = "课程类型")
    private String courseType;

    @NotEmpty(message = "课程描述不能为空", groups = Insert.class)
    @ApiModelProperty(value = "课程描述",required = true)
    private String description;

    @Future(message = "开始时间,不能在当前时间之前")
    @NotEmpty(message = "开课时间不能为空", groups = Insert.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="Asia/Shanghai")
    @ApiModelProperty(value = "开课时间",required = true)
    private String startTime;

    @Future(message = "结课时间,不能在当前时间之前")
    @NotEmpty(message = "结课时间不能为空", groups = Insert.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="Asia/Shanghai")
    @ApiModelProperty(value = "结课时间",required = true)
    private String endTime;

    @Digits(integer = 3, fraction=2, message = "金额格式错误", groups = {Insert.class,Update.class})
    @DecimalMin(value = "0.00", message = "金额最小值不能低于0.00元", groups = {Insert.class,Update.class})
    @NotNull(message = "课程价格不能为空", groups = Insert.class)
    @ApiModelProperty(value = "课程价格",required = true)
    private BigDecimal coursePrice;

    @ApiModelProperty(value = "课程状态",required = true)
    private Integer status;

    @PositiveOrZero(message = "请填写正整数",groups = {Insert.class,Update.class})
    @ApiModelProperty(value = "课程库存",required = true)
    private Integer courseInventory;


    @ApiModelProperty(value = "课时")
    private List<String> periodIdList;

}
